﻿@model DingTalkAgent.Web.Models.SysP_Page
@{
    ViewBag.Title = "list";
    Layout = "~/Views/Shared/_Layout.cshtml";
}

    <div class="wrapper wrapper-content  animated fadeInRight">
        <div class="row">
            <div class="col-sm-12">
                <div class="ibox ">
                    <div class="ibox-title">
                            <h5>页面管理</h5>
                        </div>
                    <div class="ibox-content">
                        <form role="form" class="form-inline" id="form1" name="form1">
                            <div class="form-group">
                                <label for="exampleInputEmail2" class="sr-only">关键字</label>
                                <input type="text" placeholder="请输入关键字" id="keyword" name="keyword" class="form-control">
                            </div>
                            <button class="btn btn-primary" type="button" onclick="add()">添加</button>
                            <button class="btn btn-white" type="button" id="btnsearch">查询</button>
                        </form>
                    </div>
                    <div class="ibox-content">
                        <div class="jqGrid_wrapper">
                            <table id="table_list_1"></table>
                            <div id="pager_list_1"></div>
                        </div>
                        <p>&nbsp;</p>

                    </div>
                </div>
            </div>
        </div>
    </div>

    <script>
        $(document).ready(function () {

            $("#btnsearch").click(function () {
                $("#table_list_1").jqGrid('setGridParam', {
                    postData: $('#form1').serializeObject(),
                    page: 1
                }).trigger("reloadGrid"); //重新载入
            });

            $.jgrid.defaults.styleUI = 'Bootstrap';
            $("#table_list_1").jqGrid({
                url: '/SysBase/SysPList',
                datatype: "json",
                mtype: 'POST',
                height: 'auto',
                autowidth: true,
                shrinkToFit: true,
                multiselect: true,
                multiboxonly: true,
                postData:$('#form1').serializeObject(),
                cellEdit: true,
                rowNum: 10,
                rowList: [10, 20, 30],
                colNames: ['Page_ID', '页名字', '上层页面', 'Controller', 'Action', '排序编号', '是否启用', '操作'],
                colModel: [
                    {
                        name: 'Page_ID',
                        index: 'Page_ID',
                        width: '10%',

                    },
                    {
                        name: 'Name',
                        index: 'Name',
                        width: '10%',
                    },
                    {
                        name: 'Parent_ID',
                        index: 'Parent_ID',
                        width: '10%',
                    },
                    {
                        name: 'Controller',
                        index: 'Controller',
                        width: '15%',
                    },
                    {
                        name: 'Action',
                        index: 'Action',
                        width: '15%',
                    },
                    {
                        name: 'OrderID',
                        index: 'OrderID',
                        width: '10%',
                    },
                    {
                        name: 'active',
                        index: 'active',
                        width: '10%',
                    },
                    {
                        label: '修改', name: 'Page_ID', index: 'Page_ID', width: '20%', align: 'center',
                         formatter: function (cellvalue, options, rowObject) {
                             var actionlink1 = "&apos;/SysBase/SysPDelete&apos;";

                             return "<a data-toggle='modal' href='SysPEdit?ID=" + cellvalue + "'data-target='#mmXgmodal'>修改</a> | <a href='#' onclick='javascript:Delete(" + cellvalue + "," + actionlink1 + ")'>删除</a>  | <a onclick='openSysAList(" + cellvalue + ")' href='#'>功能管理</a>";
                         },
                     },
                ],
                jsonReader: {
                    root: "List",
                    page: "page",
                    total: "total",
                    records: "records",
                    repeatitems: false,
                },
                pager: "#pager_list_1",
                viewrecords: true,
                hidegrid: false
            });
            // Add responsive to jqGrid
            $(window).bind('resize', function () {
                var width = $('.jqGrid_wrapper').width();
                $('#table_list_1').setGridWidth(width);
            });
            $('#mmXgmodal').on('hidden.bs.modal', function () {
                $(this).removeData('bs.modal');
            });
        });

        function add()
        {
            $("#mmXgmodal").modal({
                remote: "SysPAdd"
            });
        }
        function openSysAList(Page_ID) {
            layer.open({
                type: 2,
                title: false,
                skin: 'layui-layer-lan',
                shadeClose: false,
                shade: 0.3,
                scrollbar :false,
                area: ['1000px', '700px'],
                content: '/SysBase/SysAList?Page_ID=' + Page_ID
            });
        }
    </script>

    <div class="modal fade" id="mmXgmodal" tabindex="-1" role="dialog" aria-labelledby="modal">
        <div class="modal-dialog" role="document">
            <div class="modal-content">

            </div>
        </div>
    </div>
